using System.Collections.Generic;
using System.ComponentModel;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Tests
{
	/// <summary>
	/// 
	/// </summary>
	internal class TestComponentContainer : IContainer
	{
		private readonly List<IComponent> components = new List<IComponent>();

		#region IContainer Members

		/// <summary>
		/// Adds the specified <see cref="T:System.ComponentModel.IComponent"/> to the <see cref="T:System.ComponentModel.IContainer"/> at the end of the list.
		/// </summary>
		/// <param name="component">The <see cref="T:System.ComponentModel.IComponent"/> to add.</param>
		public void Add(IComponent component)
		{
			components.Add(component);
		}

		/// <summary>
		/// Adds the specified <see cref="T:System.ComponentModel.IComponent"/> to the <see cref="T:System.ComponentModel.IContainer"/> at the end of the list, and assigns a name to the component.
		/// </summary>
		/// <param name="component">The <see cref="T:System.ComponentModel.IComponent"/> to add.</param>
		/// <param name="name">The unique, case-insensitive name to assign to the component.-or- null that leaves the component unnamed.</param>
		public void Add(IComponent component, string name)
		{
			components.Add(component);
		}

		/// <summary>
		/// Removes a component from the <see cref="T:System.ComponentModel.IContainer"/>.
		/// </summary>
		/// <param name="component">The <see cref="T:System.ComponentModel.IComponent"/> to remove.</param>
		public void Remove(IComponent component)
		{
			components.Remove(component);
		}

		/// <summary>
		/// Gets all the components in the <see cref="T:System.ComponentModel.IContainer"/>.
		/// </summary>
		/// <value></value>
		/// <returns>A collection of <see cref="T:System.ComponentModel.IComponent"/> objects that represents all the components in the <see cref="T:System.ComponentModel.IContainer"/>.</returns>
		public ComponentCollection Components
		{
			get { return new ComponentCollection(components.ToArray()); }
		}

		#endregion

		#region IDisposable Members

		/// <summary>
		/// Performs application-defined tasks associated with freeing,
		/// releasing, or resetting unmanaged resources.
		/// </summary>
		public void Dispose()
		{
			return;
		}

		#endregion
	}
}